package com.ruoyi.service.equipment.impl;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.equipment.MesEquipment;
import com.ruoyi.mapper.equipment.MesEquipmentMapper;
import com.ruoyi.service.equipment.IMesEquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 设备信息Service业务层处理
 * 
 * @author ruoyi
 */
@Service
public class MesEquipmentServiceImpl implements IMesEquipmentService
{
    @Autowired
    private MesEquipmentMapper mesEquipmentMapper;

    /**
     * 查询设备信息
     * 
     * @param equipmentId 设备信息主键
     * @return 设备信息
     */
    @Override
    public MesEquipment selectMesEquipmentByEquipmentId(Long equipmentId)
    {
        return mesEquipmentMapper.selectMesEquipmentByEquipmentId(equipmentId);
    }

    /**
     * 查询设备信息列表
     * 
     * @param mesEquipment 设备信息
     * @return 设备信息
     */
    @Override
    public List<MesEquipment> selectMesEquipmentList(MesEquipment mesEquipment)
    {
        return mesEquipmentMapper.selectMesEquipmentList(mesEquipment);
    }

    /**
     * 校验设备编码是否唯一
     * 
     * @param equipmentCode 设备编码
     * @return 结果
     */
    @Override
    public String checkEquipmentCodeUnique(String equipmentCode)
    {
        MesEquipment equipment = mesEquipmentMapper.checkEquipmentCodeUnique(equipmentCode);
        if (StringUtils.isNotNull(equipment))
        {
            return "1"; // 不唯一
        }
        return "0"; // 唯一
    }

    /**
     * 新增设备信息
     * 
     * @param mesEquipment 设备信息
     * @return 结果
     */
    @Override
    public int insertMesEquipment(MesEquipment mesEquipment)
    {
        return mesEquipmentMapper.insertMesEquipment(mesEquipment);
    }

    /**
     * 修改设备信息
     * 
     * @param mesEquipment 设备信息
     * @return 结果
     */
    @Override
    public int updateMesEquipment(MesEquipment mesEquipment)
    {
        return mesEquipmentMapper.updateMesEquipment(mesEquipment);
    }

    /**
     * 批量删除设备信息
     * 
     * @param equipmentIds 需要删除的数据主键集合
     * @return 结果
     */
    @Override
    public int deleteMesEquipmentByEquipmentIds(Long[] equipmentIds)
    {
        return mesEquipmentMapper.deleteMesEquipmentByEquipmentIds(equipmentIds);
    }

    /**
     * 删除设备信息
     * 
     * @param equipmentId 设备信息主键
     * @return 结果
     */
    @Override
    public int deleteMesEquipmentByEquipmentId(Long equipmentId)
    {
        return mesEquipmentMapper.deleteMesEquipmentByEquipmentId(equipmentId);
    }
}